package com.hujiheng.paike.common.lang;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private String code;
    private String msg;
    private Object data;

    public static Result success(Object data) {
        return Result.success("操作成功", data);
    }

    public static Result success(String msg, Object data) {
        Result result = new Result();
        result.setCode("200");
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    public static Result fail(String msg) {
        return Result.fail(msg, null);
    }

    public static Result fail(String msg, Object data) {
        Result result = new Result();
        result.setCode("400");
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
}
